package com.theme.passport.dao.theme;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.theme.common.mvc.utils.PageUtils;
import com.theme.passport.entity.theme.TabActivationCode;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface TabActivationCodeDao extends BaseMapper<TabActivationCode> {

    @Select(
            "<script>select t0.* from tab_activation_code t0 " +
                    //add here if need left join
                    "where 1=1" +
                    "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
                    "<when test='activationCode!=null and activationCode!=&apos;&apos; '> and t0.activation_code=#{activationCode}</when> " +
                    "<when test='isUsed!=null and isUsed!=&apos;&apos; '> and t0.is_used=#{isUsed}</when> " +
                    "<when test='createTime!=null and createTime!=&apos;&apos; '> and t0.create_time=#{createTime}</when> " +
                    "<when test='usedTime!=null and usedTime!=&apos;&apos; '> and t0.used_time=#{usedTime}</when> " +
                    "<when test='useUserId!=null and useUserId!=&apos;&apos; '> and t0.use_user_id=#{useUserId}</when> " +
                    //add here if need page limit
                    //" limit ${page},${limit} " +
                    " </script>")
    List<TabActivationCode> pageAll(TabActivationCode queryParamDTO, int page, int limit);

    @Select("<script>select count(1) from tab_activation_code t0 " +
            //add here if need left join
            "where 1=1" +
            "<when test='id!=null and id!=&apos;&apos; '> and t0.id=#{id}</when> " +
            "<when test='activationCode!=null and activationCode!=&apos;&apos; '> and t0.activation_code=#{activationCode}</when> " +
            "<when test='isUsed!=null and isUsed!=&apos;&apos; '> and t0.is_used=#{isUsed}</when> " +
            "<when test='createTime!=null and createTime!=&apos;&apos; '> and t0.create_time=#{createTime}</when> " +
            "<when test='usedTime!=null and usedTime!=&apos;&apos; '> and t0.used_time=#{usedTime}</when> " +
            "<when test='useUserId!=null and useUserId!=&apos;&apos; '> and t0.use_user_id=#{useUserId}</when> " +
            " </script>")
    int countAll(TabActivationCode queryParamDTO);

}